package view.render.weapon
{
	import enums.ColorLib;
	import enums.main.UISize;
	
	import feathers.controls.Label;
	
	import model.vo.weapon.GreatSwordMotionVo;
	
	import starling.utils.Color;
	
	import view.render.BaseScrollerItem;
	
	
	/**
	 * 大剑动作值列表item
	 * @author £iang
	 * 
	 */	
	public class GreatSwordMotionItem extends BaseScrollerItem
	{
		//-----------------------------
		// variables
		//-----------------------------
		
		/** 动作值信息 */
		public var motionNumLabel:Label;
		/** 物理补正信息 */
		public var physicalAddLabel:Label;
		/** 属性补正信息 */
		public var attriAddLabel:Label;
		/** 灭气信息 */
		public var fatigueLabel:Label;
		
		//-----------------------------
		// properties
		//-----------------------------
		
		//-----------------------------
		// setter&getter
		//-----------------------------
		
		//-----------------------------
		// methods
		//-----------------------------
		
		/**
		 * 初始化函数 
		 * 
		 */		
		override protected function initializeOther():void
		{
			super.initializeOther();
			motionNumLabel = new Label();
			scollerContainer.addChild( motionNumLabel );
			
			physicalAddLabel = new Label();
			physicalAddLabel.textRendererProperties.isHTML = true;
			scollerContainer.addChild( physicalAddLabel );
			
			attriAddLabel = new Label();
			attriAddLabel.textRendererProperties.isHTML = true;
			scollerContainer.addChild( attriAddLabel );
			
			fatigueLabel = new Label();
			scollerContainer.addChild( fatigueLabel );
		}
		
		/**
		 * 调整组件 
		 * 
		 */		
		override protected function draw():void
		{
			var labelY:Number = ( _itemH - 
				43 ) / 2 * UISize.DPI_SCALE;
			var padding:Number = UISize.TITLE_PADDING_LEFT * UISize.DPI_SCALE;
			var firstLabelFullW:Number;
			
			firstLabel.x = padding;
			firstLabelFullW = UISize.MAIN_W * _firstPercent;
			
			motionNumLabel.y = labelY;
			motionNumLabel.x = 0;
			motionNumLabel.width  = UISize.MAIN_W * 0.3;
			
			physicalAddLabel.y = labelY;
			physicalAddLabel.x = UISize.MAIN_W * 0.3;
			physicalAddLabel.width  = UISize.MAIN_W * 0.3;
			
			attriAddLabel.y = labelY;
			attriAddLabel.x = UISize.MAIN_W * 0.6;
			attriAddLabel.width  = UISize.MAIN_W * 0.3;
			
			fatigueLabel.y = labelY;
			fatigueLabel.x = UISize.MAIN_W * 0.9;
			fatigueLabel.width  = UISize.MAIN_W * 0.3;
			
			scollerContainer.x = firstLabelFullW;
			scollerContainer.height = _itemH * UISize.DPI_SCALE;
			scollerContainer.width = UISize.MAIN_W - firstLabelFullW;
			
			this.width = UISize.MAIN_W;
			this.height = _itemH * UISize.DPI_SCALE;
		}
		
		/**
		 * 设置item数据 
		 * @param data 数据
		 * 
		 */		
		public function setData( data:GreatSwordMotionVo ):void
		{
			var tmpColor:uint;
			
			firstLabel.text = data.attackName;
			motionNumLabel.text = data.motionNum;
			tmpColor = data.physicalAdd > 100 ? ColorLib.IMPORTANT : Color.WHITE;
			physicalAddLabel.text = '<font color="#' + tmpColor.toString( 16 ) + '">' + data.physicalAdd + '%</font>';
			tmpColor = data.attriAdd > 100 ? ColorLib.IMPORTANT : Color.WHITE;
			attriAddLabel.text = '<font color="#' + tmpColor.toString( 16 ) + '">' + data.attriAdd + '%</font>';
			fatigueLabel.text = data.fatigue;
		}
		
		//-----------------------------
		// events
		//-----------------------------
		
		//-----------------------------
		// dispose
		//-----------------------------
		
		/**
		 * 析构滚动条容器中的标签 
		 * 
		 */		
		protected override function disposeAnythingInContainer():void
		{
			disposeLabels( [
				"motionNum", "physicalAdd",
				"attriAdd", "fatigue"
			] );
		}
		//-----------------------------
		// construction
		//-----------------------------
		
		/**
		 * 构造函数
		 *
		 */
		public function GreatSwordMotionItem()
		{
			super();
			_itemH = UISize.GREAT_SWORD_MOTION_ITEM_H;
			_firstPercent = 0.4;
			initialize();
		}
	}
}